home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume12 / cake / part08 < prev    next >
Encoding:
Internet Message Format  |  1987-10-15  |  41.9 KB

  1. Subject:  v12i014:  Cake, a make replacement, Part08/09
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rs@uunet.UU.NET
  5.  
  6. Submitted-by: Zoltan Somogyi <zs@munnari.oz>
  7. Posting-number: Volume 12, Issue 14
  8. Archive-name: cake/part08
  9.  
  10. [  There are some missing font-change commands, I believe, but it's
  11.    still quite readable.  --r$  ]
  12. #! /bin/sh
  13. # This is a shell archive, meaning:
  14. # 1. Remove everything above the #! /bin/sh line.
  15. # 2. Save the resulting text in a file.
  16. # 3. Execute the file with /bin/sh (not csh) to create:
  17. #    paper.bib
  18. # This archive created: Wed Oct 14 20:28:43 1987
  19. export PATH; PATH=/bin:/usr/bin:$PATH
  20. echo mkdir Man
  21. mkdir Man
  22. echo cd Man
  23. cd Man
  24. echo shar: "extracting 'paper.bib'" '(40457 characters)'
  25. if test -f 'paper.bib'
  26. then
  27.     echo shar: "will not over-write existing file 'paper.bib'"
  28. else
  29. sed 's/^X//' << \SHAR_EOF > 'paper.bib'
  30. X.\"        Nroff macros for papers
  31. X.\"
  32. X.\"        General setup
  33. X.nr ii 5n
  34. X.nr pi 5n
  35. X.nr fi 0
  36. X.nh
  37. X.\"         Simulated thesis mode
  38. X.de si
  39. X.po 1i
  40. X.he ''- % -''
  41. X..
  42. X.\"        Title begin
  43. X.de tb
  44. X.(l C
  45. X..
  46. X.\"        Title end
  47. X.de te
  48. X.)l
  49. X..
  50. X.\"        Abstract begin
  51. X.de ab
  52. X.ll -16n
  53. X.po +8n
  54. X.(l C
  55. X\fBAbstract\fP
  56. X.)l
  57. X..
  58. X.\"        Abstract end
  59. X.de ae
  60. X
  61. X.ll +16n
  62. X.po -8n
  63. X..
  64. X.\"        Title spacing
  65. X.de ts
  66. X\&
  67. X.sp 1.45i
  68. X..
  69. X.\"        Melbourne University address
  70. X.de mu
  71. XDepartment of Computer Science
  72. XUniversity of Melbourne
  73. XParkville, 3052 Victoria, Australia
  74. X..
  75. X.\"        Zoltan Somogyi's address
  76. X.de zs
  77. X.po +8m
  78. X.(l M
  79. XUUCP:        {uunet,mcvax,ukc}!munnari.oz!zs
  80. XARPA:        zs%munnari.oz@uunet.uu.net
  81. XCSNET:    zs%munnari.oz@australia
  82. X.)l
  83. X.po -8m
  84. X..
  85. X.\"        Computing Reviews categories
  86. X.de cr
  87. X.lp
  88. X\fBCR Categories and Subject Descriptors:\fP
  89. X.br
  90. X..
  91. X.\"        Keywords
  92. X.de kw
  93. X.lp
  94. X\fBAdditional Keywords and Phrases:\fP
  95. X.br
  96. X..
  97. X.\"        Tech report offsets etc
  98. X.de to
  99. X.br
  100. X.he ''- % -''
  101. X.pn 1
  102. X.po 1.2i
  103. X.bp
  104. X..
  105. X.\"        Acknowledge the ACrb
  106. X.de rb
  107. X.(f
  108. XThis research was supported by the Australian Computer Research Board.
  109. X.)f
  110. X..
  111. X.\"        Setup for theorem numbering
  112. X.de $1
  113. X.nr tn 0 1
  114. X..
  115. X.\"        Theorem
  116. X.de tr
  117. X.lp
  118. X.b "Theorem \\n($1.\\n+(tn"
  119. X..
  120. X.\"        Lemma
  121. X.de le
  122. X.lp
  123. X.b "Lemma \\n($1.\\n+(tn"
  124. X..
  125. X.\"        Corollary
  126. X.de co
  127. X.lp
  128. X.b "Corollary \\n($1.\\n+(tn"
  129. X..
  130. X.\"        Proof
  131. X.de pr
  132. X.lp
  133. X.b "Proof"
  134. X.br
  135. X..
  136. X.\"        Proof end
  137. X.de pe
  138. X.b "[]"
  139. X.br
  140. X..
  141. X.\"        Definition of terms
  142. X.de dt
  143. X.lp
  144. X.b "Definition"
  145. X..
  146. X.\"        Example
  147. X.de ea
  148. X.lp
  149. X.b "Example"
  150. X..
  151. X.\"        Program begin
  152. X.de (p
  153. X.sp .05i
  154. X.ft as
  155. X.nf
  156. X..
  157. X.\"        Program end
  158. X.de )p
  159. X.fi
  160. X.ft R
  161. X.sp .05i
  162. X..
  163. X.\"        Print contents page
  164. X.de ct
  165. X.he ''''
  166. X.bp
  167. X.ls 1
  168. X.sp 4
  169. X.ce 1
  170. X\fIContents\fP
  171. X.ce 0
  172. X.sp
  173. X.xp
  174. X..
  175. X.\"        Generate index
  176. X.de $0                
  177. X.(x
  178. X.if "\\$3"1" .sp
  179. X'in \\$3m*5u-5u
  180. X\fI\\$2. \\$1\fR
  181. X'in
  182. X.)x
  183. X..
  184. X.\"        Begin quote
  185. X.de (Q
  186. X.br
  187. X.nr po +\\n(iiu
  188. X.xl -\\n(iiu
  189. X.nr Gr \\n($r
  190. X.vs \\n(.vu+12p/2u
  191. X.nr $r \\n(.vu/\\n(.su
  192. X.lp
  193. X..
  194. X.\"        End quote
  195. X.de )Q                
  196. X.nr po 0
  197. X.xl
  198. X.nr $r \\n(Gr
  199. X..
  200. X.ds l] /usr/bib/bmac
  201. X.\"    Zoltan's bib macros
  202. X.ds [[ [
  203. X.ds ]] ]
  204. X.ds ], ,\|
  205. X.ds ]- -
  206. X.ds [. " \&
  207. X.ds .] .
  208. X.ds [, " \&
  209. X.ds ,] ,
  210. X.ds [? " \&
  211. X.ds ?] ?
  212. X.ds [: " \&
  213. X.ds :] :
  214. X.ds [; " \&
  215. X.ds ;] ;
  216. X.ds [! " \&
  217. X.ds !] !
  218. X.ds [" " \&
  219. X.ds "] \&"
  220. X.ds [' " \&
  221. X.ds '] '
  222. X.ds [< " \&
  223. X.ds >]
  224. X.\" reference formmating strings
  225. X.ds a] " \&
  226. X.ds b] , \&
  227. X.ds c] , \&
  228. X.ds n] "\&, and \&
  229. X.ds m] "\&, and \&
  230. X.ds p] .
  231. X.\" reference formmating macros
  232. X.de s[    \" start reference
  233. X.nh
  234. X.IP [\\*([F] 5m
  235. X..
  236. X.de e[    \" end reference
  237. X.[-
  238. X..
  239. X.de []    \" start to display collected references
  240. X.LP
  241. X..
  242. X.de ][    \" choose format
  243. X.ie "\\*([T""           .nr t[ 9    \" notitle
  244. X.el \{\
  245. X.  ie !"\\*([J"" \{\
  246. X.    ie !"\\*([V""      .nr t[ 1    \" journal
  247. X.    el                 .nr t[ 5    \" conference paper
  248. X.  \}
  249. X.  el \{\
  250. X.    ie !"\\*([R""      .nr t[ 4    \" technical report
  251. X.    el \{\
  252. X.      ie "\\*([I""     .nr t[ 0    \" other (inverted test)
  253. X.      el \{\
  254. X.        ie !"\\*([B""  .nr t[ 3    \" article in book
  255. X.        el             .nr t[ 2    \" book
  256. X.      \}
  257. X.    \}
  258. X.  \}
  259. X.\}
  260. X.\\n(t[[
  261. X..
  262. X.de 0[    \" other
  263. X.s[
  264. X.tm bmac.zs: using other for \\*([T
  265. X.if !"\\*([A"" \\*([A\c
  266. X.if !"\\*([T"" , \\*([T\c
  267. X.if !"\\*([I"" , \\*([I\c
  268. X.if !"\\*([C"" , \\*([C\c
  269. X.if !"\\*([V"" , vol. \\*([V\c
  270. X.if !"\\*([D"" , \\*([D\c
  271. X.if !"\\*([O"" , \\*([O\c
  272. X\&.
  273. X.e[
  274. X..
  275. X.de 1[    \" journal article
  276. X.s[
  277. X.ie !"\\*([A"" \\*([A,
  278. X.el \{\
  279. X.  ie !"\\*([E"" \{\
  280. X.    ie \\n([E-1 \\*([E\\0(eds.),
  281. X.    el \\*([E\\0(ed.),
  282. X.  \}
  283. X.  el .tm bmac.zs: no author/editor for journal article "\\*([T"
  284. X.\}
  285. X\\*([T\c
  286. X, \\fI\\*([J\\fP, \\*([V\c
  287. X.if !"\\*([N"" :\\*([N\c
  288. X.ie !"\\*([D"" \\ \\|(\\*([D)\c
  289. X.el .tm bmac.zs: no date for journal article "\\*([T"
  290. X.ie !"\\*([P"" \{\
  291. X.  ie \\n([P , pp. \\*([P\c
  292. X.  el , p. \\*([P\c
  293. X.\}
  294. X.el .tm bmac.zs: no page numbers for journal article \\*([T
  295. X.if !"\\*([O"" , \\*([O\c
  296. X\\&.
  297. X.e[
  298. X..
  299. X.de 2[    \" book
  300. X.s[
  301. X.ie !"\\*([A"" \\*([A,
  302. X.el \{\
  303. X.  ie !"\\*([E"" \{\
  304. X.    ie \\n([E-1 \\*([E\\0(eds.),
  305. X.    el \\*([E\\0(ed.),
  306. X.  \}
  307. X.  el .tm bmac.zs: no author/editor for book "\\*([T"
  308. X.\}
  309. X\\*([T\c
  310. X.if !"\\*([S"" , \\*([S\c
  311. X.if !"\\*([S"" \{\
  312. X.  ie !"\\*([V"" volume \\& \\*([V\c
  313. X.  el .if !"\\*([N"" \\& \\*([N\c
  314. X.\}
  315. X.ie !"\\*([I"" , \\*([I\c
  316. X.el .tm bmac.zs: no publisher for book "\\*([T"
  317. X.ie !"\\*([C"" , \\*([C\c
  318. X.el .tm bmac.zs: no city for book "\\*([T"
  319. X.ie !"\\*([D"" , \\*([D\c
  320. X.el .tm bmac.zs: no date for book "\\*([T"
  321. X.if !"\\*([O"" , \\*([O\c
  322. X\\&.
  323. X.e[
  324. X..
  325. X.de 3[    \" article in book
  326. X.s[
  327. X.ie !"\\*([A"" \\*([A,
  328. X.el .tm bmac.zs: no author for article in book "\\*([T"
  329. X\\*([T,\\0in:\\0\c
  330. X.ie !"\\*([E"" \{\
  331. X.  ie \\n([E-1 \\*([E\\0(eds.),
  332. X.  el \\*([E\\0(ed.),
  333. X.\}
  334. X.el .tm bmac.zs: no editor for article in book "\\*([T"
  335. X\\fI\\*([B\\fP\c
  336. X.if !"\\*([S"" , \\*([S\c
  337. X.if !"\\*([S"" \{\
  338. X.  ie !"\\*([V"" \\& volume \\*([V\c
  339. X.  el .if !"\\*([N"" \\& \\*([N\c
  340. X.\}
  341. X.ie !"\\*([I"" , \\*([I\c
  342. X.el .tm bmac.zs: no publisher for article in book "\\*([T"
  343. X.ie !"\\*([C"" , \\*([C\c
  344. X.el .tm bmac.zs: no city for article in book "\\*([T"
  345. X.ie !"\\*([D"" , \\*([D\c
  346. X.el .tm bmac.zs: no date for article in book "\\*([T"
  347. X.if !"\\*([P"" \{\
  348. X.  ie \\n([P , pp. \\*([P\c
  349. X.  el , p. \\*([P\c
  350. X.\}
  351. X.if !"\\*([O"" , \\*([O\c
  352. X\\&.
  353. X.e[
  354. X..
  355. X.de 4[    \" report
  356. X.s[
  357. X.ie !"\\*([A"" \\*([A,
  358. X.el \{\
  359. X.  ie !"\\*([E"" \{\
  360. X.    ie \\n([E-1 \\*([E\\0(eds.),
  361. X.    el \\*([E\\0(ed.),
  362. X.  \}
  363. X.  el .tm bmac.zs: no author/editor for report "\\*([T"
  364. X.\}
  365. X\\*([T, \\*([R\c
  366. X.ie !"\\*([I"" , \\*([I\c
  367. X.el .tm bmac.zs: no publisher for report "\\*([T"
  368. X.ie !"\\*([C"" , \\*([C\c
  369. X.el .tm bmac.zs: no city for report "\\*([T"
  370. X.ie !"\\*([D"" , \\*([D\c
  371. X.el .tm bmac.zs: no date for report "\\*([T"
  372. X.if !"\\*([O"" , \\*([O\c
  373. X\\&.
  374. X.e[
  375. X..
  376. X.de 5[    \" conference paper
  377. X.s[
  378. X.ie !"\\*([A"" \\*([A,
  379. X.el \{\
  380. X.  ie !"\\*([E"" \{\
  381. X.    ie \\n([E-1 \\*([E\\0(eds.),
  382. X.    el \\*([E\\0(ed.),
  383. X.  \}
  384. X.  el .tm bmac.zs: no author/editor for conference paper "\\*([T"
  385. X.\}
  386. X\\*([T, \\fI\\*([J\\fP\c
  387. X.ie !"\\*([C"" , \\*([C\c
  388. X.el .tm bmac.zs: no city for conference paper "\\*([T"
  389. X.if !"\\*([I"" , \\*([I\c
  390. X.ie !"\\*([D"" , \\*([D\c
  391. X.el .tm bmac.zs: no date for conference paper "\\*([T"
  392. X.ie !"\\*([P"" \{\
  393. X.  ie \\n([P , pp. \\*([P\c
  394. X.  el , p. \\*([P\c
  395. X.\}
  396. X.el .tm bmac.zs: no page numbers for conference paper \\*([T
  397. X.if !"\\*([O"" , \\*([O\c
  398. X\\&.
  399. X.e[
  400. X..
  401. X.de 9[    \" notitle
  402. X.s[
  403. X.tm bmac.zs: reference with no title
  404. X.if !"\\*([A"" \\*([A\c
  405. X.if !"\\*([E"" , ed. \\*([E\c
  406. X.if !"\\*([I"" , \\*([I\c
  407. X.if !"\\*([C"" , \\*([C\c
  408. X.if !"\\*([V"" , vol. \\*([V\c
  409. X.if !"\\*([D"" , \\*([D\c
  410. X.if !"\\*([O"" , \\*([O\c
  411. X\&.
  412. X.e[
  413. X..
  414. X.de [-    \" clean up after yourself
  415. X.rm [A [B [C [D
  416. X.rm [E [F [G [H
  417. X.rm [I [J [K
  418. X.rm [N [O [P
  419. X.rm [R [T
  420. X.rm [V [W
  421. X..
  422. X.ds [[ (
  423. X.ds ]] )
  424. X.ds ], ; 
  425. X.\"            Start references section
  426. X.de []
  427. X.ls 1
  428. X.ne 4
  429. X.sh 1 "References"
  430. X.sp 1
  431. X.nr ii 16
  432. X..
  433. X.\"            Start reference
  434. X.de s[
  435. X.nh
  436. X.ip (\\*([F)
  437. X..
  438. X.\"            End reference
  439. X.de e[
  440. X.[-
  441. X..
  442. X.\"    NEED bib tbl eqn
  443. X.tb
  444. X\f(CBCake\fP:\fB a fifth generation version of \f(CBmake\fP\fR
  445. X.sp
  446. XZoltan Somogyi
  447. XDepartment of Computer Science
  448. XUniversity of Melbourne
  449. Xzs@mulga.OZ
  450. X.sp 2
  451. X.ab
  452. X.lp
  453. X\f(asMake\fP is a standard Unix\** utility
  454. Xfor maintaining computer programs.
  455. X\f(asCake\fP is a rewrite of \f(asmake\fP from the ground up.
  456. XThe main difference is one of attitude:
  457. X\f(ascake\fP is considerably more general and flexible,
  458. Xand can be extended and customized to a much greater extent.
  459. XIt is applicable to a wide range of domains,
  460. Xnot just program development.
  461. X.(f
  462. X\** Unix is a trademark of AT&T Bell Laboratories.
  463. X.)f
  464. X.ae
  465. X.fo ''- % -''
  466. X.ta 0.4i 0.8i 1.2i 1.6i 2.0i 2.4i 2.8i 3.2 3.6i 4.0i 4.4i 4.8i 5.2i 5.6i
  467. X.EQ
  468. Xdelim off
  469. X.EN
  470. X.sp 2
  471. X.\"
  472. X.sh 1 "Introduction"
  473. X.\"
  474. X.lp
  475. XThe Unix utility \f(asmake\fP\*([<\*([[Feldman,\ 79\*(]]\*(>]
  476. Xwas written to automate the compilation and recompilation of C programs.
  477. XPeople have found \f(asmake\fP so successful in this domain
  478. Xthat they do not wish to be without its services
  479. Xeven when they are working in other domains.
  480. XSince \f(asmake\fP was not designed with these domains in mind
  481. X(some of which, e.g. VLSI design,
  482. Xdid not even exist when \f(asmake\fP was written),
  483. Xthis causes problems and complaints.
  484. XNevertheless, implied in these complaints
  485. Xis an enormous compliment to the designers of \f(asmake\fP;
  486. Xone does not hear many grumbles
  487. Xabout programs with only a few users.
  488. X.pp
  489. XThe version of \f(asmake\fP described in\*([<\*([[Feldman,\ 79\*(]]\*(>]
  490. Xis the standard utility.
  491. XAT&T modified it in several respects for distribution with System V
  492. Xunder the name \f(asaugmented make\fP\*([<\*([[AT&T,\ 84\*(]]\*(>].
  493. XWe know of two complete rewrites:
  494. X\f(asenhanced make\fP\*([<\*([[Hirgelt,\ 83\*(]]\*(>]
  495. Xand \f(asfourth generation make\fP\*([<\*([[Fowler,\ 85\*(]]\*(>].
  496. XAll these versions remain oriented towards program maintenance.
  497. X.pp
  498. XHere at Melbourne we wanted something we could use for text processing.
  499. XWe had access only to standard \f(asmake\fP
  500. Xand spent a lot of time wrestling with \f(asmakefiles\fP
  501. Xthat kept on getting bigger and bigger.
  502. XFor a while we thought about modifying the \f(asmake\fP source,
  503. Xbut then decided to write something completely new.
  504. XThe basic problem was
  505. Xthe inflexibility of \f(asmake's\fP search algorithm,
  506. Xand this algorithm is too embedded in the \f(asmake\fP source
  507. Xto be changed easily.
  508. X.pp
  509. XThe name \f(ascake\fP is a historical accident.
  510. X\f(asCake\fP follows two other programs
  511. Xwhose names were also puns on \f(asmake\fP.
  512. XOne was \f(asbake\fP, a variant of \f(asmake\fP
  513. Xwith built-in rules for VLSI designs instead of C programs
  514. X\*([[Gedye,\ 84\*(]].
  515. XThe other was David Morley's shell script \f(asfake\fP.
  516. XWritten at a time when disc space on our machine was extremely scarce,
  517. Xand full file systems frequently caused write failures,
  518. Xit copied the contents of a directory to \f(as/tmp\fP
  519. Xand invoked \f(asmake\fP there.
  520. X.pp
  521. XThe structure of the paper is as follows.
  522. XSection 2 shows how \f(ascake\fP solves
  523. Xthe main problems with \f(asmake\fP,
  524. Xwhile section 3 describes
  525. Xthe most important new features of \f(ascake\fP.
  526. XThe topics of section 4 are portability and efficiency.
  527. X.lp
  528. XThe paper assumes that you have some knowledge of \f(asmake\fP.
  529. X.\"
  530. X.sh 1 "The problems with \f(CBmake\fP"
  531. X.\"
  532. X.lp
  533. X\f(asMake\fP has three principal problems.
  534. XThese are:
  535. X.np
  536. XIt supports only suffix-based rules.
  537. X.np
  538. XIts search algorithm is not flexible enough.
  539. X.np
  540. XIt has no provisions for the sharing of new \f(asmake\fP rules.
  541. X.pp
  542. XThese problems are built deep into \f(asmake\fP.
  543. XTo solve them we had to start again from scratch.
  544. XWe had to abandon backward compatibility because
  545. Xthe \f(asmake\fP syntax is not rich enough to represent
  546. Xthe complex relationships among the components of large systems.
  547. XNevertheless, the \f(ascake\fP user interface
  548. Xis deliberately based on \f(asmake's\fP;
  549. Xthis helps users to transfer their skills
  550. Xfrom \f(asmake\fP to \f(ascake\fP.
  551. XThe \fIfunctionalities\fP of the two systems
  552. Xare sufficiently different that the risk of confusion is minimal\**.
  553. X.(f
  554. X\**
  555. XThis problem, called cognitive dissonance, is discussed in
  556. XWeinberg's delightful book\*([<\*([[Weinberg,\ 71\*(]]\*(>].
  557. X.)f
  558. X.pp
  559. XProbably the biggest single difference
  560. Xbetween \f(asmake\fP and \f(ascake\fP lies in their general attitudes.
  561. X\f(asMake\fP is focused on one domain:
  562. Xthe maintenance of compiled programs.
  563. XIt has a lot of code specific to this domain
  564. X(especially the later versions).
  565. XAnd it crams all its functionality into some tight syntax
  566. Xthat treats all sorts of special things (e.g. \f(as.SUFFIXES\fP)
  567. Xas if they were files.
  568. X.pp
  569. X\f(asCake\fP, on the other hand,
  570. Xuses different syntax for different things,
  571. Xand keeps the number of its mechanisms to the minimum
  572. Xconsistent with generality and flexibility.
  573. XThis attitude throws a lot of the functionality of \f(asmake\fP
  574. Xover the fence into the provinces of other programs.
  575. XFor example, where \f(asmake\fP has its own macro processor,
  576. X\f(ascake\fP uses the C preprocessor;
  577. Xand where \f(asmake\fP has special code to handle archives,
  578. X\f(ascake\fP has a general mechanism
  579. Xthat \fIjust happens\fP to be able to do the same job.
  580. X.\"
  581. X.sh 2 "Only suffix-based rules"
  582. X.\"
  583. X.lp
  584. XAll entries in a \f(asmakefile\fP have the same syntax.
  585. XThey do not, however, have the same semantics.
  586. XThe main division is between
  587. Xentries which describe simple dependencies
  588. X(how to make file \f(asa\fP from file \f(asb\fP),
  589. Xand those which describe rules
  590. X(how to make files with suffix \f(as.x\fP
  591. Xfrom files with suffix \f(as.y\fP)\**.
  592. X\f(asMake\fP distinguishes the two cases by treating as a rule
  593. Xany dependency whose target is a concatenation of two suffixes.
  594. X.(f
  595. X\**
  596. XFor the moment we ignore entries whose targets are special entities
  597. Xlike .IGNORE .PRECIOUS etc.
  598. X.)f
  599. X.pp
  600. XFor this scheme to work, \f(asmake\fP must assume three things.
  601. XThe first is that all interesting files have suffixes;
  602. Xthe second is that suffixes always begin with a period;
  603. Xthe third is that prefixes are not important.
  604. XAll three assumptions are violated in fairly common situations.
  605. XStandard \f(asmake\fP cannot express the relationship
  606. Xbetween \f(asfile\fP and \f(asfile.c\fP (executable and source)
  607. Xbecause of assumption 1,
  608. Xbetween \f(asfile\fP and \f(asfile,v\fP (working file and RCS file)
  609. Xbecause of assumption 2,
  610. Xand between \f(asfile.o\fP and \f(as../src/file.c\fP (object and source)
  611. Xbecause of assumption 3.
  612. X\f(asEnhanced make\fP and \f(asfourth generation make\fP
  613. Xhave special forms for some of these cases,
  614. Xbut these cannot be considered solutions
  615. Xbecause special forms will always lag behind demand for them
  616. X(they are embedded in the \f(asmake\fP source,
  617. Xand are therefore harder to change than even the built-in rules).
  618. X.pp
  619. X\f(asCake's\fP solution is
  620. Xto do away with \f(asmake\fP-style rules altogether
  621. Xand instead to allow ordinary dependencies to function as rules
  622. Xby permitting them to contain variables.
  623. XFor example, a possible rule for compiling C programs is
  624. X.(b M
  625. X.(p
  626. X%.o:        %.c
  627. X        cc -c %.c
  628. X.)p
  629. X.)b
  630. Xwhere the \f(as%\fP is the variable symbol.
  631. XThis rule is actually a \fItemplate\fP
  632. Xfor an infinite number of dependencies,
  633. Xeach of which is obtained
  634. Xby consistently substituting a string for the variable \f(as%\fP.
  635. X.pp
  636. XThe way this works is as follows.
  637. XFirst, as \f(ascake\fP seeks to update a file,
  638. Xit matches the name of that file
  639. Xagainst all the targets in the description file.
  640. XThis matching process gives values to the variables in the target.
  641. XThese values are then substituted in the rest of the rule\**.
  642. X(The matching operation is a form of \fIunification\fP,
  643. Xthe process at the heart of logic programming;
  644. Xthis is the reason for the \fIfifth generation\fP bit in the title.)
  645. X.(f
  646. X\**
  647. XAfter this the rule should have no unexpanded variables in it.
  648. XIf it does, \f(ascake\fP reports an error,
  649. Xas it has no way of finding out
  650. Xwhat the values of those variables should be.
  651. X.)f
  652. X.pp
  653. X\f(asCake\fP actually supports 11 variables:
  654. X\f(as%\fP and \f(as%0\fP to \f(as%9\fP.
  655. XA majority of rules in practice have only one variable
  656. X(canonically called \f(as%\fP), and most of the other rules have two
  657. X(canonically called \f(as%1\fP and \f(as%2\fP).
  658. XThese variables are local to their rules.
  659. XNamed variables are therefore not needed,
  660. Xthough it would be easy to modify the \f(ascake\fP source to allow them.
  661. X.ea
  662. XIf \f(ascake\fP wanted to update \f(asprog.o\fP,
  663. Xit would match \f(asprog.o\fP against \f(as%.o\fP,
  664. Xsubstitute \f(asprog\fP for \f(as%\fP throughout the entry,
  665. Xand then proceed as if the \f(ascakefile\fP contained the entry
  666. X.(b M
  667. X.(p
  668. Xprog.o:    prog.c
  669. X        cc -c prog.c
  670. X.)p
  671. X.)b
  672. X.lp
  673. XThis arrangement has a number of advantages.
  674. XOne can write
  675. X.(b M
  676. X.(p
  677. X%.o:        RCS/%.c,v
  678. X        co -u %.c
  679. X        cc -c %.c
  680. X.)p
  681. X.)b
  682. Xwithout worrying about the fact that one of the files in the rule
  683. Xwas in a different directory and that
  684. Xits suffix started with a nonstandard character.
  685. XAnother advantage is that rules are not restricted to
  686. Xhaving one source and one target file.
  687. XThis is useful in VLSI,
  688. Xwhere one frequently needs rules like
  689. X.(b M
  690. X.(p
  691. X%.out:    %.in %.circuit
  692. X        simulator %.circuit < %.in > %.out
  693. X.)p
  694. X.)b
  695. Xand it can also be useful to describe
  696. Xthe full consequences of running \f(asyacc\fP
  697. X.(b M
  698. X.(p
  699. X%.c %.h:    %.y
  700. X        yacc -d %.y
  701. X        mv y.tab.c %.c
  702. X        mv y.tab.h %.h
  703. X.)p
  704. X.)b
  705. X.\"
  706. X.sh 2 "Inflexible search algorithm"
  707. X.\"
  708. X.lp
  709. XIn trying to write a \f(asmakefile\fP
  710. Xfor a domain other than program development,
  711. Xthe biggest problem one faces
  712. Xis usually \f(asmake's\fP search algorithm.
  713. XThe basis of this algorithm is a special list of suffixes.
  714. XWhen looking for ways to update a target \f(asfile.x\fP,
  715. X\f(asmake\fP searches along this list from left to right.
  716. XIt uses the first suffix \f(as.y\fP
  717. Xfor which it has a rule \f(as.y.x\fP
  718. Xand for which \f(asfile.y\fP exists.
  719. X.pp
  720. XThe problem with this algorithm manifests itself
  721. Xwhen a problem divides naturally into a number of stages.
  722. XSuppose that you have two rules \f(as.c.b\fP and \f(as.b.a\fP,
  723. Xthat \f(asfile.c\fP exists
  724. Xand you want to issue the command \f(asmake file.a\fP.
  725. X\f(asMake\fP will tell you
  726. Xthat it doesn't know how to make \f(asfile.a\fP.
  727. XThe problem is that for the suffix \f(as.b\fP
  728. X\f(asmake\fP has a rule but no file,
  729. Xwhile for \f(as.c\fP it has a file but no rule.
  730. X\f(asMake\fP needs a \fItransitive rule\fP \f(as.c.a\fP
  731. Xto go direct from \f(asfile.c\fP to \f(asfile.a\fP.
  732. X.pp
  733. XThe number of transitive rules increases
  734. Xas the square of the number of processing stages.
  735. XIt therefore becomes significant for program development
  736. Xonly when one adds processing stages on either side of compilers.
  737. XUnder Unix, these stages are typically the link editor \f(asld\fP
  738. Xand program generators like \f(asyacc\fP and \f(aslex\fP.
  739. XHalf of standard \f(asmake's\fP builtin rules are transitive ones,
  740. Xthere to take care of these three programs.
  741. XEven so, the builtin rules do not form a closure:
  742. Xsome rare combinations of suffixes are missing
  743. X(e.g. there is no rule for going from \f(asyacc\fP source to assembler).
  744. X.pp
  745. XFor builtin rules a slop factor of two may be acceptable.
  746. XFor rules supplied by the user it is not.
  747. XA general-purpose \f(asmakefile\fP for text processing under Unix
  748. Xneeds at least six processing stages to handle
  749. X\f(asnroff/troff\fP and their preprocessors
  750. X\f(aslbl\fP, \f(asbib\fP, \f(aspic\fP, \f(astbl\fP, and \f(aseqn\fP,
  751. Xto mention only the ones in common use at Melbourne University.
  752. X.pp
  753. X\f(asCake's\fP solution is simple:
  754. Xif \f(asfile1\fP can be made from \f(asfile2\fP
  755. Xbut \f(asfile2\fP does not exist,
  756. X\f(ascake\fP will try to \fIcreate\fP \f(asfile2\fP.
  757. XPerhaps \f(asfile2\fP can be made from \f(asfile3\fP,
  758. Xwhich can be made from \f(asfile4\fP,
  759. Xand so on, until we come to a file which does exist.
  760. X\f(asCake\fP will give up only when there is \fIabsolutely no way\fP
  761. Xfor it to generate a feasible update path.
  762. X.pp
  763. XBoth the standard and later versions of \f(asmake\fP
  764. Xconsider missing files to be out of date.
  765. XSo if \f(asfile1\fP depends on \f(asfile2\fP
  766. Xwhich depends on \f(asfile3\fP,
  767. Xand \f(asfile2\fP is missing, then \f(asmake\fP will remake
  768. Xfirst \f(asfile2\fP and then \f(asfile1\fP,
  769. Xeven if \f(asfile1\fP is more recent than \f(asfile3\fP.
  770. X.pp
  771. XWhen using \f(asyacc\fP, I frequently remove generated sources
  772. Xto prevent duplicate matches when I run \f(asegrep ... *.[chyl]\fP.
  773. XIf \f(ascake\fP adopted \f(asmake's\fP approach to missing files,
  774. Xit would do a lot of unnecessary work,
  775. Xrunning \f(asyacc\fP and \f(ascc\fP to generate
  776. Xthe same parser object again and again\**.
  777. X.(f
  778. X\**
  779. XIn this case \f(asmake\fP is rescued from this unnecessary work
  780. Xby its built-in transitive rules,
  781. Xbut as shown above this should not be considered
  782. Xa \fIgeneral\fP solution.
  783. X.)f
  784. X.pp
  785. X\f(asCake\fP solves this problem
  786. Xby associating dates even with missing files.
  787. XThe \fItheoretical update time\fP of an existing file
  788. Xis its modify time (as given by stat(2));
  789. Xthe theoretical update time of a missing file
  790. Xis the theoretical update time of its youngest ancestor.
  791. XSuppose the \f(asyacc\fP source \f(asparser.y\fP
  792. Xis older than the parser object \f(asparser.o\fP,
  793. Xand \f(asparser.c\fP is missing.
  794. X\f(asCake\fP will figure that if it recreated \f(asparser.c\fP
  795. Xit would get a \f(asparser.c\fP which \fItheoretically\fP
  796. Xwas last modified at the same time as \f(asparser.y\fP was,
  797. Xand since \f(asparser.o\fP is younger than \f(asparser.y\fP,
  798. Xtheoretically it is younger than \f(asparser.c\fP as well,
  799. Xand therefore up-to-date.
  800. X.\"
  801. X.sh 2 "No provisions for sharing rules"
  802. X.\"
  803. X.lp
  804. XImagine that you have just written a program
  805. Xthat would normally be invoked from a \f(asmake\fP rule,
  806. Xsuch as a compiler for a new language.
  807. XYou want to make both the program and the \f(asmake\fP rule
  808. Xwidely available.
  809. XWith standard \f(asmake\fP, you have two choices.
  810. XYou can hand out copies of the rules
  811. Xand get users to include it in their individual \f(asmakefiles\fP;
  812. Xor you can modify the \f(asmake\fP source,
  813. Xspecifically, the file containing the built-in rules.
  814. XThe first way is error-prone and quite inconvenient
  815. X(all those rules cluttering up your \f(asmakefile\fP
  816. Xwhen you should never need to even look at them).
  817. XThe second way can be impractical;
  818. Xin the development stage because the rules can change frequently
  819. Xand after that because you want to distribute your program
  820. Xto sites that may lack the \f(asmake\fP source.
  821. XAnd of course two such modifications may conflict with one another.
  822. X.pp
  823. XLogically, your rules belong in a place
  824. Xthat is less permanent than the \f(asmake\fP source
  825. Xbut not as transitory as individual \f(asmakefiles\fP.
  826. XA library file is such a place.
  827. XThe obvious way to access the contents of library files
  828. Xis with \f(as#include\fP, so \f(ascake\fP filters
  829. Xevery \f(ascakefile\fP through the C preprocessor.
  830. X.pp
  831. X\f(asCake\fP relies on this mechanism
  832. Xto the extent of not having \fIany\fP built-in rules at all.
  833. XThe standard \f(ascake\fP rules live in files
  834. Xin a library directory (usually /usr/lib/cake).
  835. XEach of these files contains rules about one tool or group of tools.
  836. XMost user \f(ascakefiles\fP \f(as#define\fP some macros
  837. Xand then include some of these files.
  838. XGiven that the source for program \f(asprog\fP
  839. Xis distributed among \f(asprog.c\fP,
  840. X\f(asaux1.c\fP, \f(asaux2.c\fP, and \f(asparser.y\fP,
  841. Xall of which depend on \f(asdef.h\fP,
  842. Xthe following would be a suitable \f(ascakefile\fP:
  843. X.(b M
  844. X.(p
  845. X#define    MAIN        prog
  846. X#define    FILES    prog aux1 aux2 parser
  847. X#define    HDR        def.h
  848. X
  849. X#include    <Yacc>
  850. X#include    <C>
  851. X#include    <Main>
  852. X.)p
  853. X.)b
  854. XThe standard \f(ascakefiles\fP
  855. X\f(asYacc\fP and \f(asC\fP, as might be expected,
  856. Xcontain rules that invoke \f(asyacc\fP and \f(ascc\fP respectively.
  857. XThey also provide some definitions
  858. Xfor the standard \f(ascakefile\fP \f(asMain\fP.
  859. XThis file contains rules about programs in general,
  860. Xand is adaptable to all compiled languages
  861. X(e.g. it can handle NU-Prolog programs).
  862. XOne entry in \f(asMain\fP links the object files together,
  863. Xanother prints out all the sources,
  864. Xa third creates a \f(astags\fP file
  865. Xif the language has a command equivalent to \f(asctags\fP,
  866. Xand so on.
  867. X.pp
  868. X\f(asMake\fP needs a specialized macro processor;
  869. Xwithout one it cannot substitute the proper filenames in rule bodies.
  870. X\f(asFourth generation make\fP has not solved this problem
  871. Xbut it still wants the extra functionality of the C preprocessor,
  872. Xso it grinds its \f(asmakefiles\fP through both macro processors !
  873. X\f(asCake\fP solves the problem in another way,
  874. Xand can thus rely on the C preprocessor exclusively.
  875. X.pp
  876. XThe original \f(asmake\fP mechanisms are quite rudimentary,
  877. Xas admitted by\*([<\*([[Feldman,\ 79\*(]]\*(>].
  878. XUnfortunately, the C preprocessor is not without flaws either.
  879. XThe most annoying is that
  880. Xthe bodies of macro definitions may begin with blanks,
  881. Xand will if the body is separated from the macro name and any parameters
  882. Xby more than one blank (whether space or tab).
  883. X\f(asCake\fP is distributed with a fix to this problem
  884. Xin the form of a one-line change to the preprocessor source,
  885. Xbut this change probably will not work on all versions of Unix
  886. Xand definitely will not work for binary-only sites.
  887. X.\"
  888. X.sh 1 "The new features of \f(CBcake\fP"
  889. X.\"
  890. X.lp
  891. XThe above solutions to \f(asmake's\fP problems are useful,
  892. Xbut they do not by themselves enable \f(ascake\fP to handle new domains.
  893. XFor this \f(ascake\fP employs two important new mechanisms:
  894. Xdynamic dependencies and conditional rules.
  895. X.\"
  896. X.sh 2 "Dynamic dependencies"
  897. X.\"
  898. X.lp
  899. XIn some situations it is not convenient to list in advance
  900. Xthe names of the files a target depends on.
  901. XFor example, an object file depends
  902. Xnot only on the corresponding source file
  903. Xbut also on the header files referenced in the source.
  904. X.pp
  905. XStandard \f(asmake\fP requires all these dependencies
  906. Xto be declared explicitly in the \f(asmakefile\fP.
  907. XSince there can be rather a lot of these, most people either
  908. Xdeclare that all objects depend on all headers, which is wasteful,
  909. Xor declare a subset of the true dependencies, which is error-prone.
  910. XA third alternative is to use a program (probably an \f(asawk\fP script)
  911. Xto derive the dependencies and edit them into the \f(asmakefile\fP.
  912. X\*([[Walden,\ 84\*(]] describes one program that does both these things;
  913. Xthere are others.
  914. XThese systems are usually called \f(asmake\%depend\fP
  915. Xor some variation of this name.
  916. X.pp
  917. XThe problems with this approach are that
  918. Xit is easy to alter the automatically-derived dependencies by mistake,
  919. Xand that if a new header dependency is added
  920. Xthe programmer must remember to run \f(asmakedepend\fP again.
  921. XThe C preprocessor solves the first problem;
  922. Xthe second, however, is the more important one.
  923. XIts solution must involve scanning though the source file,
  924. Xchecking if the programmer omitted to declare a header dependency.
  925. XSo why not use this scan
  926. Xto \fIfind\fP the header dependencies in the first place ?
  927. X.pp
  928. X\f(asCake\fP attacks this point directly
  929. Xby allowing parts of rules to be specified at run-time.
  930. XA command enclosed in double square brackets\** may appear in a rule
  931. Xanywhere a filename or a list of filenames may appear.
  932. X.(f
  933. X\**
  934. XSingle square brackets (like most special characters)
  935. Xare meaningful to \f(ascsh\fP: they denote character classes.
  936. XHowever, we are not aware of any legitimate contexts where
  937. Xtwo square brackets \fImust\fP appear together.
  938. XThe order of members in such classes is irrelevant,
  939. Xso if a bracket must be a member of such a class
  940. Xit can be positioned away from the offending boundary
  941. X(unless the class is a singleton,
  942. Xin which case there is no need for the class in the first place).
  943. X.)f
  944. XFor the example of the C header files, the rule would be
  945. X.(b M
  946. X.(p
  947. X%.o:        %.c [[ccincl %.c]]
  948. X        cc -c %.c
  949. X.)p
  950. X.)b
  951. X.lp
  952. Xsignifying that \f(asx.o\fP depends on the files
  953. Xwhose names are listed in the output of the command
  954. X\f(asccincl x.c\fP\**, as well as on \f(asx.c\fP.
  955. X.(f
  956. X\**
  957. X\f(asCcincl\fP prints out the names of the files
  958. Xthat are \f(as#included\fP in the file named by its argument.
  959. X.)f
  960. XThe matching process would convert this rule to
  961. X.(b M
  962. X.(p
  963. Xx.o:        x.c [[ccincl x.c]]
  964. X        cc -c x.c
  965. X.)p
  966. X.)b
  967. Xwhich in turn would be \fIcommand expanded\fP to
  968. X.(b M
  969. X.(p
  970. Xx.o:        x.c hdr.h
  971. X        cc -c x.c
  972. X.)p
  973. X.)b
  974. Xif \f(ashdr.h\fP were the only header included in \f(asx.c\fP.
  975. X.pp
  976. XCommand patterns provide replacements
  977. Xfor \f(asfourth generation make's\fP
  978. Xdirectory searches and special macros.
  979. X\f(as[[find\ <dirs>\ -name\ <filename>\ -print]]\fP
  980. Xdoes as good a job as the special-purpose \f(asmake\fP code
  981. Xin looking up source files scattered among a number of directories.
  982. X\f(as[[basename\ <filename>\ <suffix>]]\fP can do an even better job:
  983. X\f(asmake\fP cannot extract the base from the name of an RCS file.
  984. X.pp
  985. XA number of tools intended to be used in just such contexts
  986. Xare distributed together with \f(ascake\fP.
  987. X\f(asCcincl\fP is one.
  988. X\f(asSub\fP is another: its purpose is to perform substitutions.
  989. XIts arguments are two patterns and some strings:
  990. Xit matches each string against the first pattern,
  991. Xgiving values to its variables;
  992. Xthen it applies those values to the second pattern
  993. Xand prints out the result of this substitution.
  994. XFor example, in the example of section 2.3
  995. Xthe \f(ascakefile\fP \f(asMain\fP would invoke
  996. Xthe command \f(as[[sub\ X\ X.o\ FILES]]\fP\**,
  997. Xthe value of \f(asFILES\fP being \f(asprog aux1 aux2 parser\fP,
  998. Xto find that the object files it must link together
  999. Xto create the executable \f(asprog\fP are
  1000. X\f(asprog.o aux1.o aux2.o parser.o\fP.
  1001. X.(f
  1002. X\**
  1003. X\f(asSub\fP uses \f(asX\fP as the character denoting variables.
  1004. XIt cannot use \f(as%\fP,
  1005. Xas all \f(as%\fP's in the command will have been substituted for
  1006. Xby \f(ascake\fP by the time \f(assub\fP is invoked.
  1007. X.)f
  1008. X.pp
  1009. X\f(asCake\fP allows commands to be nested inside one another.
  1010. XFor example, the command \f(as[[sub\ X.h\ X\ [[ccincl\ file.c]]]]\fP
  1011. Xwould strip the suffix \f(as.h\fP
  1012. Xfrom the names of the header files included in \f(asfile.c\fP\**.
  1013. X.(f
  1014. X\**
  1015. XAs the outputs of commands are substituted
  1016. Xfor the commands themselves,
  1017. X\f(ascake\fP takes care not to scan the new text,
  1018. Xlest it find new double square brackets
  1019. Xand go into an infinite loop.
  1020. X.)f
  1021. X.\"
  1022. X.sh 2 "Conditional rules"
  1023. X.\"
  1024. X.lp
  1025. XSometimes it is natural to say that
  1026. X\f(asfile1\fP depends on \f(asfile2\fP
  1027. X\fIif\fP some condition holds.
  1028. XNone of the \f(asmake\fP variants provide for this,
  1029. Xbut it was not too hard
  1030. Xto incorporate conditional rules into \f(ascake\fP.
  1031. X.pp
  1032. XA \f(ascake\fP entry may have a condition associated with it.
  1033. XThis condition, which is introduced by the reserved word \f(asif\fP,
  1034. Xis a boolean expression built up with the operators
  1035. X\f(asand\fP, \f(asor\fP and \f(asnot\fP from primitive conditions.
  1036. X.pp
  1037. XThe most important primitive
  1038. Xis a command enclosed in double curly braces.
  1039. XWhenever \f(ascake\fP considers applying this rule,
  1040. Xit will execute this command
  1041. Xafter matching, substitution and command expansion.
  1042. XThe condition will return true if the command's exit status is zero.
  1043. XThis runs counter to the intuition of C programmers,
  1044. Xbut it conforms to the Unix convention
  1045. Xof commands returning zero status when no abnormal conditions arise.
  1046. XFor example, \f(as{{grep\ xyzzy\ file}}\fP returns
  1047. Xzero (i.e. true) if xyzzy occurs in \f(asfile\fP
  1048. Xand nonzero (false) otherwise.
  1049. X.pp
  1050. XConceptually, this one primitive is all one needs.
  1051. XHowever, it has considerable overhead,
  1052. Xso \f(ascake\fP includes other primitives to handle some special cases.
  1053. XThese test whether a filename occurs in a list of filenames,
  1054. Xwhether a pattern matches another,
  1055. Xand whether a file with a given name exists.
  1056. XThree others forms test the internal \f(ascake\fP status of targets.
  1057. XThis status is \f(asok\fP
  1058. Xif the file was up-to-date when \f(ascake\fP was invoked,
  1059. X\f(ascando\fP if it wasn't but \f(ascake\fP knows how to update it,
  1060. Xand \f(asnoway\fP if \f(ascake\fP does not know how to update it.
  1061. X.pp
  1062. XAs an example, consider the rule for RCS.
  1063. X.(b M
  1064. X.(p
  1065. X%:        RCS/%,v        if exist RCS/%,v
  1066. X        co -u %
  1067. X.)p
  1068. X.)b
  1069. XWithout the condition
  1070. Xthe rule would apply to all files,
  1071. Xeven ones which were not controlled by RCS,
  1072. Xand even the RCS files themselves:
  1073. Xthere would be no way to stop the infinite recursion
  1074. X(\f(as%\fP depends on \f(asRCS/%,v\fP
  1075. Xwhich depends on \f(asRCS/RCS/%,v,v\fP ...).
  1076. X.pp
  1077. XNote that conditions are command expanded
  1078. Xjust like other parts of entries,
  1079. Xso it is possible to write
  1080. X.(b M
  1081. X.(p
  1082. X%:        archive        if % in [[ar t archive]]
  1083. X        ar x archive %
  1084. X.)p
  1085. X.)b
  1086. X.\" .\"
  1087. X.\" .sh 1 "Details"
  1088. X.\" .\"
  1089. X.\" .\"
  1090. X.\" .sh 2 "Flags"
  1091. X.\" .\"
  1092. X.\" .lp
  1093. X.\" Flags after patterns and actions
  1094. X.\" \f(asCake\fP actions are very similar to \f(asmake\fP actions.
  1095. X.\" .\"
  1096. X.\" .sh 2 "Error handling"
  1097. X.\" .\"
  1098. X.\" .lp
  1099. X.\" After error discovered the nodes involved arenot touched again ...
  1100. X.\" Propagation of errors.
  1101. X.\" Detect circular dependencies.
  1102. X.\" .\"
  1103. X.\" .sh 2 "Options"
  1104. X.\" .\"
  1105. X.\" .lp
  1106. X.\" \f(asCake\fP has even more options than \f(asmake\fP\** does.
  1107. X.\" .(f
  1108. X.\" \**
  1109. X.\" I refer to standard \f(asmake\fP;
  1110. X.\" I do not have sufficient documentation on the other versions
  1111. X.\" to say whether this point holds for them or not
  1112. X.\" (but I expect that it would).
  1113. X.\" .)f
  1114. X.\" The ones that the two have in common generally do the same things.
  1115. X.\" .\" -D ...
  1116. X.\" .lp
  1117. X.\" \f(asCake\fP looks for options in environment (in the envariable CAKE),
  1118. X.\" on the command line (the usual place), and in the \f(ascakefile\fP,
  1119. X.\" consulted in that order, with later definitions overriding earlier ones.
  1120. X.\" The fact that options in the \f(ascakefile\fP
  1121. X.\" can override those on the command line is somewhat unusual.
  1122. X.\" Certainly some options (such as -n, print actions but do not execute)
  1123. X.\" should not be placed in the \f(ascakefile\fP.
  1124. X.\" On the other hand,
  1125. X.\" the \f(ascakefile\fP cannot be consulted before the command line,
  1126. X.\" as the command line may specify the name of the \f(ascakefile\fP !
  1127. X.\" So instead of adding code to check that such conflicts do not occur
  1128. X.\" we trust the programmer not to do such silly things in the first place.
  1129. X.\" .\"
  1130. X.\" .sh 1 "Standard \f(ascakefile\fPs"
  1131. X.\" .\"
  1132. X.\" .lp
  1133. X.\" Main and System do everything (really?) that 4g make do
  1134. X.\"
  1135. X.sh 1 "The implementation"
  1136. X.\"
  1137. X.sh 2 "Portability"
  1138. X.\"
  1139. X.lp
  1140. X\f(asCake\fP was developed on a Pyramid 90x under 4.2bsd.
  1141. XIt now runs on a VAX under 4.3bsd,
  1142. Xa Perkin-Elmer 3240 and an ELXSI 6400 under 4.2bsd,
  1143. Xand on the same ELXSI under System V.
  1144. XIt has not been tested on either System III or version 7.
  1145. X.pp
  1146. X\f(asCake\fP is written in standard C,
  1147. Xwith (hopefully) all machine dependencies
  1148. Xisolated in the makefile and a header file.
  1149. XIn a number of places it uses \f(as#ifdef\fP
  1150. Xto choose between pieces of code
  1151. Xappropriate to the AT&T and Berkeley variants of Unix
  1152. X(e.g. to choose between \f(astime()\fP and \f(asgettimeofday()\fP).
  1153. XIn fact, the biggest hassle we have encountered in porting \f(ascake\fP
  1154. Xwas caused by the standard header files.
  1155. XSome files had different locations on different machines
  1156. X(\f(as/usr/include\fP vs. \f(as/usr/include/sys\fP),
  1157. Xand the some versions included other header files
  1158. X(typically \f(astypes.h\fP) while others did not.
  1159. X.pp
  1160. XAs distributed \f(ascake\fP is set up to work with \f(ascsh\fP,
  1161. Xbut it is a simple matter to specify another shell at installation time.
  1162. X(In any case, users may substitute their preferred shell
  1163. Xby specifying a few options.)
  1164. XSome of the auxiliary commands are implemented as \f(ascsh\fP scripts,
  1165. Xbut these are small and it should be trivial
  1166. Xto convert them to another shell if necessary.
  1167. X.\"
  1168. X.sh 2 "Efficiency"
  1169. X.\"
  1170. X.lp
  1171. X\f(asFourth generation make\fP
  1172. Xhas a very effective optimization system.
  1173. XFirst, it forks and execs only once.
  1174. XIt creates one shell, and thereafter,
  1175. Xit pipes commands to be executed to this shell
  1176. Xand gets back status information via another pipe.
  1177. XSecond, it compiles its \f(asmakefiles\fP into internal form,
  1178. Xavoiding parsing except when the compiled version
  1179. Xis out of date with respect to the master.
  1180. X.pp
  1181. XThe first of these optimizations is an absolute winner.
  1182. X\f(asCake\fP does not have it
  1183. Xfor the simple reason that it requires a shell
  1184. Xwhich can transmit status information back to its parent process,
  1185. Xand we don't have access to one
  1186. X(this feature is provided by neither of the standard shells,
  1187. X\f(assh\fP and \f(ascsh\fP).
  1188. X.pp
  1189. X\f(asCake\fP could possibly make use of the second optimization.
  1190. XIt would involve keeping track
  1191. Xof the files the C preprocessor includes,
  1192. Xso that the \f(asmakefile\fP can be recompiled if one of them changes;
  1193. Xthis must be done by fourth generation make as well
  1194. Xthough\*([<\*([[Fowler,\ 85\*(]]\*(>] does not mention it.
  1195. XHowever, the idea is not as big a win for \f(ascake\fP
  1196. Xas it is for \f(asmake\fP.
  1197. XThe reason is as follows.
  1198. X.pp
  1199. XThe basic motivations for using \f(ascake\fP rather than \f(asmake\fP
  1200. Xis that it allows one to express more complex dependencies.
  1201. XThis implies a bigger system,
  1202. Xwith more and slower commands
  1203. Xthan the ones \f(asmake\fP usually deals with.
  1204. XThe times taken by \f(ascake\fP and the preprocessor
  1205. Xare insignificant when compared to the time taken
  1206. Xby the programs it most often invokes at Melbourne.
  1207. XThese programs, \f(asditroff\fP and \f(asnc\fP
  1208. X(the NU-Prolog compiler that is itself written in NU-Prolog),
  1209. Xare notorious CPU hogs.
  1210. X.pp
  1211. XHere are some statistics to back up this argument.
  1212. XThe \fIoverhead ratio\fP is given by the formula
  1213. X.EQ
  1214. X{ "cake process system time"
  1215. X~ + ~ "children user time"
  1216. X~ + ~ "children system time" }
  1217. Xover "cake process user time"
  1218. X.EN
  1219. XThis is justifiable given that the \f(ascake\fP implementor
  1220. Xhas direct control only over the denominator;
  1221. Xthe kernel and the user's commands
  1222. Ximpose a lower limit on the numerator.
  1223. X.\" .(b L
  1224. X.\" .TS
  1225. X.\" center allbox;
  1226. X.\" c s s
  1227. X.\" c c c
  1228. X.\" n n n
  1229. X.\" n n n
  1230. X.\" n n n
  1231. X.\" n n n
  1232. X.\" n n n
  1233. X.\" c n n.
  1234. X.\" overhead ratio
  1235. X.\" quantile    munmurra    mulga
  1236. X.\" 10    1.65    1.63
  1237. X.\" 25    22.92    2.69
  1238. X.\" 50    67.55    4.87
  1239. X.\" 75    105.07    22.93
  1240. X.\" 90    164.91    178.60
  1241. X.\" average    81.75    69.75
  1242. X.\" .TE
  1243. X.\" .(l C
  1244. X.\" Table 1.
  1245. X.\" .)l
  1246. X.\" .)b
  1247. X.\" .lp
  1248. X.\" Table 1. displays statistics
  1249. X.\" collected on every \f(ascake\fP run on two machines at Melbourne\**.
  1250. X.pp
  1251. XWe have collected statistics
  1252. Xon every \f(ascake\fP run on two machines at Melbourne\**.
  1253. X.(f
  1254. X\**
  1255. XOn munmurra (an EXLSI 6400),
  1256. Xthe main application is Prolog compilation;
  1257. Xon mulga (a Perkin-Elmer 3240),
  1258. Xthe main applications are text processing
  1259. Xand the maintenance of a big bibliography (over 36000 references).
  1260. X.)f
  1261. XThese statistics show
  1262. Xthat the processes and system calls invoked by \f(ascake\fP
  1263. Xtake on average about 70-80 times as much CPU time
  1264. Xas the \f(ascake\fP process itself.
  1265. XThis suggests that the best way to lower total CPU time
  1266. Xis not to tune \f(ascake\fP itself
  1267. Xbut to reduce the number of child processes.
  1268. XTo this end, \f(ascake\fP caches
  1269. Xthe status returned by all condition commands \f(as{{command}}\fP
  1270. Xand the output of all command patterns \f(as[[command]]\fP.
  1271. XThe first cache has a hit ratio of about 50 percent,
  1272. Xcorresponding to the typical practice
  1273. Xin which a condition and its negation
  1274. Xselect one out of a pair of rules.
  1275. XThe second cache has a hit ratio of about 75 percent;
  1276. Xthese hits are usually the second and later occurrences
  1277. Xof macros whose values contain commands.
  1278. X.pp
  1279. X\f(asCake\fP also uses a second optimization.
  1280. XThis one is borrowed from standard \f(asmake\fP:
  1281. Xwhen an action contains no constructs requiring a shell,
  1282. X\f(ascake\fP itself will parse the action and invoke it through exec.
  1283. XWe have no statistics to show
  1284. Xwhat percentage of actions benefit from this,
  1285. Xbut a quick examination of the standard \f(ascakefiles\fP
  1286. Xleads us to believe that it is over 50 percent.
  1287. X.\" .lp
  1288. X.\" The overhead ratio average is fairly misleading.
  1289. X.\" It is dominated by big jobs
  1290. X.\" slow startup caused by planning phase
  1291. X.pp
  1292. XOverall, \f(ascake\fP can do a lot more than \f(asmake\fP,
  1293. Xbut on things which \fIcan\fP be handled by \f(asmake\fP,
  1294. X\f(ascake\fP is slightly slower than standard \f(asmake\fP
  1295. Xand a lot slower than fourth generation make.
  1296. XSince the main goal of \f(ascake\fP is generality, not efficiency,
  1297. Xthis is understandable.
  1298. XIf efficiency is important,
  1299. X\f(asmake\fP is always available as a fallback.
  1300. X.\"
  1301. X.sh 2 "Availability"
  1302. X.\"
  1303. X.lp
  1304. X\f(asCake\fP has been fairly stable for about six months now.
  1305. XDuring this time it has been used without major problems
  1306. Xby about twenty people here at Melbourne.
  1307. XIt will be posted to the net in the near future,
  1308. Xcomplete with auxiliary programs and manual entries.
  1309. X.\"
  1310. X.sh 1 "Acknowledgements"
  1311. X.\"
  1312. X.lp
  1313. XJohn Shepherd, Paul Maisano, David Morley and Jeff Schultz
  1314. Xhelped me to locate bugs
  1315. Xby being brave enough to use early versions of \f(ascake\fP.
  1316. XI would like to thank John
  1317. Xfor his comments on drafts of this paper.
  1318. X.lp
  1319. XThis research was supported by
  1320. Xa Commonwealth Postgraduate Research Award,
  1321. Xthe Australian Computer Research Board,
  1322. Xand Pyramid Australia.
  1323. X.\"
  1324. X.[]
  1325. X.[-
  1326. X.ds [F AT&T,\ 84
  1327. X.ds [Q AT&T
  1328. X.ds [T Augmented version of make
  1329. X.ds [B Unix System V - release 2.0 support tools guide
  1330. X.ds [I AT&T
  1331. X.ds [D April 1984
  1332. X.][
  1333. X.[-
  1334. X.ds [F Feldman,\ 79
  1335. X.ds [A Stuart I. Feldman
  1336. X.ds [T Make - a program for maintaining computer programs
  1337. X.ds [J Software - Practice and Experience
  1338. X.ds [V 9
  1339. X.ds [N 4
  1340. X.ds [D April 1979
  1341. X.nr [P 1
  1342. X.ds [P 255-265
  1343. X.][
  1344. X.[-
  1345. X.ds [F Fowler,\ 85
  1346. X.ds [A Glenn S. Fowler
  1347. X.ds [T A fourth generation make
  1348. X.ds [J Proceedings of the USENIX Summer Conference
  1349. X.ds [C Portland, Oregon
  1350. X.ds [D June 1985
  1351. X.nr [P 1
  1352. X.ds [P 159-174
  1353. X.][
  1354. X.[-
  1355. X.ds [F Gedye,\ 84
  1356. X.ds [A David Gedye
  1357. X.ds [T Cooking with CAD at UNSW
  1358. X.ds [I Joint Microelectronics Research Center, University of New South Wales
  1359. X.ds [C Sydney, Australia
  1360. X.ds [D 1984
  1361. X.][
  1362. X.[-
  1363. X.ds [F Hirgelt,\ 83
  1364. X.ds [A Edward Hirgelt
  1365. X.ds [T Enhancing make or re-inventing a rounder wheel
  1366. X.ds [J Proceedings of the USENIX Summer Conference
  1367. X.ds [C Toronto, Ontario, Canada
  1368. X.ds [D June 1983
  1369. X.nr [P 1
  1370. X.ds [P 45-58
  1371. X.][
  1372. X.[-
  1373. X.ds [F Walden,\ 84
  1374. X.ds [A Kim Walden
  1375. X.ds [T Automatic generation of make dependencies
  1376. X.ds [J Software - Practice and Experience
  1377. X.ds [V 14
  1378. X.ds [N 6
  1379. X.ds [D June 1984
  1380. X.nr [P 1
  1381. X.ds [P 575-585
  1382. X.][
  1383. X.[-
  1384. X.ds [F Weinberg,\ 71
  1385. X.ds [A Gerald M. Weinberg
  1386. X.ds [T The psychology of computer programming
  1387. X.ds [I Van Nostrand Reinhold
  1388. X.ds [C New York
  1389. X.ds [D 1971
  1390. X.nr [P 0
  1391. X.ds [P 288
  1392. X.][
  1393. SHAR_EOF
  1394. if test 40457 -ne "`wc -c < 'paper.bib'`"
  1395. then
  1396.     echo shar: "error transmitting 'paper.bib'" '(should have been 40457 characters)'
  1397. fi
  1398. fi
  1399. exit 0
  1400. #    End of shell archive
  1401.